package mymysql;

import com.mysql.jdbc.*;
import java.util.*;
import java.sql.*;

public class first{

    public static void main(String[] args){

	java.sql.Statement stm;
	java.sql.ResultSet rs;

	try{
	    Class.forName("com.mysql.jdbc.Driver");
	    Properties props = new Properties();
	    props.setProperty("user","mysql");
	    Enumeration menum = DriverManager.getDrivers();
	    while (menum.hasMoreElements())
		System.out.println(menum.nextElement().getClass().getName());

	    java.sql.Connection myconnection = DriverManager.getConnection("jdbc:mysql://localhost/?user=root");
	    if (myconnection != null)
		myconnection.setCatalog("library");
	    else System.out.println("null connection");

	    stm = myconnection.createStatement();
	    rs = stm.executeQuery("Select * from books");

	    while (rs.next()){
		System.out.println(rs.getString(1));
	    }
	    
	}
	catch(java.sql.SQLException e){System.out.println(e);}
	catch(java.lang.ClassNotFoundException e){System.out.println(e);}


    }

}
